import org.ice4apps.features.CoreFeature;

/**
 ******************************* ICE *******************************
 * ========================================================================
 * Project:		icefeatures
 * Package:		
 * File:		FeatureTest.java
 * Author: 		robin
 * Date: 		Jun 19, 2010
 * Description:	
 * ========================================================================
 * 
 */
public class FeatureTest {
    /**
     * @param args
     */
    public static void main (String[] args) throws Exception {
        //long a = CoreFeature.TALK.feature.enable (3);
        //System.out.println(a);
        //System.out.println(CoreFeature.TALK.feature.isEnabled (a));
        int id = 62;
        long val = Long.MAX_VALUE;
        val = setFlag(val,id,false);
        String abc = Long.toBinaryString (val);
        System.out.println(abc);
        System.out.println(abc.length ());;
        System.out.println(getFlag (id, val));
    }
    
    public static long setFlag (long value, int id, boolean flag) {
        Double pow = Math.pow (2.0, id);
        return flag ? (pow.longValue () | value) : (~(pow.longValue ()) & value);
    }
    
    public static boolean getFlag (int id, long... values) {
        Double pow = Math.pow (2.0, id);
        long a = pow.longValue ();
        boolean flag = false;
        for (long value : values) {
            flag = (value & a) == a;
            if (!flag)
                return false;
        }
        return true;
    }

}
